#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
/*printf("begin........\n");
printf("begin........\n");
printf("begin........\n");
printf("begin........\n");
execl("/bin/ls","ls","-l",NULL);
printf("end..........\n");
printf("end..........\n");
printf("end..........\n");
printf("end..........\n");*/

int ret=fork();
if(ret==0)
{
//子进程
printf("I am a child process,my pid is %d\n",getpid());
//execl("/bin/lsss","lss","-l",NULL);
//execlp("ls","ls","-l",NULL);
//char* const arr[]={"ls","-l",NULL};
//execv("/bin/ls",arr);
//char* const arr[]={"val=10",NULL};
putenv("val=10");
extern char**environ;
execle("./execldir/othertest","./othertest",NULL,environ);
//execvp("ls",arr);
//
//execl("./execldir/othertest","./othertest",NULL);
printf("The function called excel have already failed\n");
exit(1);
}
sleep(5);
//父进程
int status=0;
waitpid(ret,&status,0);
printf("I am a parent process,my pid is %d\n",getpid());
printf("My child process's exit code is %d\n",WEXITSTATUS(status));
  return 0;
}
